﻿@{
    ViewBag.Title = Model[0].Title;
}
<style>
.f16{
    font-size:16px;
}
</style>
<div class="product-detail mt10">
    <h2 class="product-title bgBlue ml5 mr5"> @Model[0].Title</h2>
        <form id="cart-form" class="cart-form" data-ajax="false" method="post" action="~/Purchase/CheckOut">
			<div class="ui-grid-a p10_0 mt5">
                <div class="ui-block-a ">
                    <img alt="" src="@Model[0].ActualImageUrl" class="product-image" />
                </div>

                <div class="ui-block-b">
                     <div class="service_rating ml20">
                          <div class="rating fl">
                            <div style="width: 80%;" class="value" rating="TotalBest"></div>
                          </div>
                     </div>
                     <div class="clear"></div>
		     <div class="price f16 mt10 ml20">原价:<SPAN style="TEXT-DECORATION: line-through;color:darkgray">￥@Model[0].MarketPrice</SPAN></div>
                     <div class="price f16 mt10 ml20">现价:￥@Model[0].UnitPrice</div>
                     <div class="clear"></div>
                    <div class="price-delivery mt10 pl25"> 

                         @if (!string.IsNullOrEmpty(@Model[0].PromotionDescription))
                         {
                            <div class="viewdesc normalwrap">
                                <ul>
                                    <li><span class="red f15">@Model[0].PromotionDescription</span></li>
                                </ul>
                            </div>
                        }
                        <div class="mt5">
                            <div class="ItemQty">
                              <div class="ReduceTable fl">
                                    <div class="Reduce gradientBlue2 mt5">
                                        <a href="#"  id="pndbtnReduce"> <div class="Reduceicon"></div></a>
                                    </div>
                                </div>
                                 <input  id="quantity" class="fl mt10 " type="number" name="quantity" value="1" data-theme="none" maxlength="3"  />
                                <div class="AddTable fl">
                                    <div class="add gradientBlue2 mt5">
                                        <a href="#" id="pndbtnAdd"> <div class="addicon"></div></a>
                                    </div>
                                </div>
                           </div>
                        </div>
                    </div>
                </div>
		</div>
        <div class="ui-grid-a">
            <div class="ui-block-a">
                @if (Model[0].TotalInventory > 0)
                {
                     <a href="#" onclick="AddToCart()" data-theme="e" data-role="button" >加入购物车</a>
                }
                else
                {
                    <a href="#" data-role="button">暂时缺货</a>
                }
               
            </div>
            <div class="ui-block-b">
                 <input type="submit" data-role="button" id="btnToCheckOut" value="立即购买" data-theme="f"></input>
            </div>
		</div>
        <p>
         	</p><div class="clear mt20"></div>
        	<span class="product-title black">@Model[0].LineDescription</span>
            <div class="clear mb20"></div>
        <p></p>
	</form>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible" data-collapsed="false">
        <h2>规格参数</h2>
        <div class="center product_desc" aria-hidden="false">
            @Html.Raw(@Model[0].DetailSpecification)
        </div>
    </div>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible">
        <h2>商品实拍</h2>
        <div class="center product_images" aria-hidden="false">
            @foreach (var item in Model[0].ImageList)
            {
                <img src="@item.ImageName" />
            }
        </div>
    </div>
</div>
<div data-role="collapsible-set">
    <div class="product-info" data-role="collapsible" id="product_over">
        <h2>商品描述</h2>
        <div class="product_overview">
            @Html.Raw(@Model[0].Overview)
        </div>
    </div>
</div>
<a href="#" onclick="AddFavority(@Model[0].ProductId,@Model[0].MarketPrice,'~/Product/ProductDetail?prd=@Model[0].ProductId')" 
   data-role="button" data-theme="e">添加关注</a>
<script language="javascript" type="text/javascript">
    var AddToCart = function () {
        try {
            var qty = $("#quantity").val();
            KevinShop.Common.ShoppingCart.UpdateToCart('@Model[0].ProductId', qty);
            KevinShop.MessageBox.Success("添加到购物车成功！");
        } catch (e) {
            alert(e);
        }
    };
    var AddFavority = function ($productId, $marketPrice, $returnUrl) {
        var $url = "AddFavority?productId=" + $productId + "&marketPrice=" + $marketPrice + "&returnUrl=" + $returnUrl;
        var $result = $.ajax({
            url: $url,
            async: false
        }).responseText;

        $result = $.parseJSON($result);

        if ($result.Status == true && $result.ErrorMessage == "ok") {
            KevinShop.MessageBox.Success("关注成功！");
        } else if ($result.Status == false && $result.ErrorStatusCode == "404") {
            window.location.href = "../Customer/Login?ReturnUrl=" + $result.ErrorMessage;
        } else if ($result.ErrorMessage == "existsProduct") {
            KevinShop.MessageBox.Warning("您已关注过此商品");
        } else {
            KevinShop.MessageBox.Warning($result.ErrorMessage);
        }
    };

    $("#pndbtnReduce").click(function () {
        var qtyText = $("#quantity").val();
        var qty = parseInt(qtyText);
        if (qty > 1) {
            qty--;
        } else {
            KevinShop.MessageBox.Alert("亲，不能再减啦。");
        };
        $("#quantity").val(qty);
    });
    $("#pndbtnAdd").click(function () {
        var qtyText = $("#quantity").val();
        var qty = parseInt(qtyText);
        if (qty < 999) {
            qty++;
        };
        $("#quantity").val(qty);
    });
    $("#btnToCheckOut").click(function () {
        var qty = $("#quantity").val();
        KevinShop.Common.ShoppingCart.UpdateToCart('@Model[0].ProductId', qty);
            $("#cart-form").submitForm();
            return false;
        });
        $(".product_overview img").attr("width", "100%");
        $(".product_overview img").removeAttr("height");
</script>